< previous page page_282 next page >

Page 282
These are just some of the reasons you may have an error occur when using a database. If any of these happen, the Error event will be triggered in the data control, and its up to you to take some appropriate action. There are other errors that can occur, and youll learn to deal with them in Chapter 17, Error Handling.
Examples Filename: Employee2.frm
Error Event
An Error event will be fired when an error is encountered in the data control. The Error event is passed an error number, description, and several other parameters. Depending on the database system youre using, the error number may be the same for all errors. This is the case for Access MDB files. In this case, its better to just display the Description parameter. The only other parameter you need to be familiar with is the fCancelDisplay parameter. You set this parameter to True if youre displaying the error yourself. This tells the data control not to display its error message once the Error event is complete. I recommend calling your own error-handling routine from this Error event. That way, you can call this procedure from every data controls Error event on the form.
EXERCISE
Add the Error Event
1. Add the following code to the Error event of the datEmployees data control:
Private Sub datEmployees_Error(_
ByVal ErrorNumber As Long, _
Description As String, _
ByVal Scode As Long, _
ByVal Source As String, _
ByVal HelpFile As String, _
ByVal HelpContext As Long, _
fCancelDisplay As Boolean)

Call DCErrorCheck(ErrorNumber, Description, fCancelDisplay)

End Sub

 
< previous page page_282 next page >

If you like this book, buy it!